using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace Brutal_Dare_Portable
{
    public class SplashScreen : Microsoft.Xna.Framework.DrawableGameComponent
    {
        SpriteBatch spriteBatch;

        string text = "The Dude and the Greb Publications Present";
        int timeElapsed = 0, timeToWait = 5000;

        public SplashScreen(Game game)
            : base(game)
        {
        }

        public override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            base.LoadContent();
        }

        public override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.PaleGoldenrod);

            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);

            spriteBatch.DrawString(((Game1)Game).introFont, text, new Vector2((int)((GraphicsDevice.Viewport.TitleSafeArea.Width / 2) - ((Game1)Game).introFont.MeasureString(text).X / 2), 5), Color.Black);

            spriteBatch.Draw(((Game1)Game).logo, new Rectangle((GraphicsDevice.Viewport.TitleSafeArea.Width / 2) - (((Game1)Game).logo.Width / 4),
                                                                (GraphicsDevice.Viewport.TitleSafeArea.Height / 2) - (((Game1)Game).logo.Height / 4),
                                                                (((Game1)Game).logo.Width / 2), (((Game1)Game).logo.Height / 2)), Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }

        public override void Update(GameTime gameTime)
        {
            timeElapsed += gameTime.ElapsedGameTime.Milliseconds;
            if (timeElapsed >= timeToWait)
            {
                ((Game1)Game).ChangeGameState(Game1.GameState.StartScreen);
            }

            base.Update(gameTime);
        }
    }
}
